﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Web.Dal
{
    public class LoginDal : ConnectionsSql
    {

        private static LoginDal _dal;

        public static LoginDal Init()
        {
            _dal = new LoginDal();

            return _dal;
        }

        internal DataTable GetUserInfo(String UWD)
        {
            SqlCommand cmd = CreateSqlCommand(
                String.Format(" SELECT * FROM [USERINFO] WHERE UWD='{0}'  ", UWD)
                , CommandType.Text);

            try
            {
                return CreateDataTable(cmd);
            }
            catch (Exception err) { throw err; }
            finally { cmd.Dispose(); }
        }

        internal DataTable GetPassword(String email)
        {
            SqlCommand cmd = CreateSqlCommand(
                String.Format(" SELECT * FROM [USERINFO] WHERE EMAIL='{0}' ", email)
                , CommandType.Text);

            try
            {
                return CreateDataTable(cmd);
            }
            catch (Exception err) { throw err; }
            finally { cmd.Dispose(); }
        }

        internal DataTable GetUserInfo(String UWD,String PWD)
        {
            SqlCommand cmd = CreateSqlCommand(
                String.Format(" SELECT * FROM [USERINFO] WHERE UWD='{0}' AND PWD='{1}' ", UWD, PWD)
                , CommandType.Text);

            try
            {
                return CreateDataTable(cmd);
            }
            catch (Exception err) { throw err; }
            finally { cmd.Dispose(); }
        }

    }
}